<template>
  <el-table :data="tableData" border style="width: 80%" class="m-auto">
    <el-table-column fixed prop="register_date" label="注册时间" width="150">
    </el-table-column>
    <el-table-column prop="name" label="用户名" width="120"> </el-table-column>
    <el-table-column prop="mobile" label="手机号" width="120">
    </el-table-column>
    <el-table-column prop="email" label="邮箱" width="120"> </el-table-column>
    <el-table-column prop="gender" label="性别" width="120"> </el-table-column>
    <el-table-column label="操作" width="100">
      <template slot-scope="scope">
        <el-button @click="handleClick(scope.row)" type="text" size="small"
          >查看</el-button
        >
        <el-button type="text" size="small" @click="deliteuser(scope.row)"
          >删除</el-button
        >
      </template>
    </el-table-column>
  </el-table>
</template>
<style scoped>
.m-auto {
  margin: 0 auto;
}
</style>
<script>
export default {
  methods: {
    // 查看指定用户
    handleClick(row) {
      console.log(row);
    },
    deliteuser(row) {
      console.log(row);
    },
  },

  data() {
    return {
      tableData: [],
    };
  },
  mounted() {
    // 发送axios请求获取商品列表
    this.$axios.get("/users/list").then((res) => {
      var { data } = res.data;
      if (res.data.code == "200") {
        data.forEach((element) => {
          element.register_date = this.moment(element.register_date).format(
            "YY-M-D H:m:s"
          );
        });
        this.tableData = data;
        console.log(data);
      }
    });
  },
};
</script>